import java.sql.*;
public class QueryExcel {
   public static void main(String args[]) { 
      try{   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//【代码1】//加载JDBC-ODBC桥接器
      }
      catch(ClassNotFoundException e) {
         System.out.print(e);
      }
      Connection con;
      Statement sql; 
      ResultSet rs;
      try { 
           con=DriverManager.getConnection("jdbc:odbc:myExcel","","");
           DatabaseMetaData metadata=con.getMetaData();
           ResultSet rs1=metadata.getColumns(null,null,"message",null);
           int 字段个数=0;
           while(rs1.next()) {
              字段个数++;
           }
           sql=con.createStatement();
           rs=sql.executeQuery("select * from message");
           while(rs.next()) {
             for(int k=1;k<=字段个数;k++) {
                 System.out.print(" "+rs.getString(k)+" ");
             }
             System.out.println("");
           }
       }
       catch(SQLException e) {
           System.out.println(""+e);
       }
   }    
}

